<template>
  <div id="app">
    <div id="nav">
      <router-link to="/">Home</router-link> |
      <router-link to="/about">About</router-link>
      <router-link to="/filter">过滤器</router-link>
    </div>
    <!-- <keep-alive include="home,about">
      <router-view />
    </keep-alive> -->
    <!-- 可以直接用字符串规定 缓存谁 用逗号隔开 也可以用正则 用正则的时候就要加上冒号了 因为正则是一个js表达式 -->
    <!-- exclude 跟 include用法一样 只不过是 规定不缓存谁 -->
    <!-- 
    <keep-alive :include="/^a/">
      <router-view />
    </keep-alive> -->

    <keep-alive>
      <router-view v-if="$route.meta.keepAlive"></router-view>
    </keep-alive>

    <router-view v-if="!$route.meta.keepAlive"></router-view>
    <!-- 也可以用路由的meta信息 去指定 哪个组件缓存哪个不缓存 -->
  </div>
</template>

<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
